/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-21 08:39:23
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-21 16:35:26
 * @FilePath: \adminstration\src\Common\Modal\ThrModalList\LabReportTemplates.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../Api/Api'
import { commonTableList } from '../config'
import { setFieldPropsOptions } from '../../Router/MenuBoxList'

export const PersonGroup = async ({ data }) => {
    let dataList = {
        uuid: data.uuid,
        type: '添加人员',
        width: 800,
        classification: 'SelectModal',
        isCheckbox: true,
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()['getPersonGroupDetailGetNoGroupPersonDetails'],
        pos: 'posPersonGroupDetail',
        assemblyData: e => {
            let list = []
            e.forEach(item => (list = [...list, { personGroupUuid: data.uuid, personUuid: item.uuid }]))
            return list
        },
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'tableName',
                title: '人员姓名',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'personTypeUuid',
                title: '人员类别',
                valueType: 'treeSelect',
                fieldProps: {
                    options: [],
                    fieldNames: { label: 'tableName', value: 'uuid' },
                },
                rules: true,
                width: 150,
            },
        ],
    }

    dataList.columns.find(v => v.dataIndex === 'personTypeUuid').fieldProps.options = await setFieldPropsOptions({
        url: 'getPersonTypeTree',
    })

    return dataList
}
